<?php
namespace app\erp_meixingtiyu\model;

use think\Model;
use think\model\concern\SoftDelete;
use app\common\model\UploadFile;
use app\api\model\User;

class Coach extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $table = 'athlon_employee';
    protected $pk = 'employee_id';

    public function image()
    {
        return $this->hasOne(UploadFile::class, 'file_id', 'image_id');
    }

    public function user()
    {
      return $this->hasOne(User::class);
    }

    public function getList()
    {
      return $this::with('image')->paginate(15);
    }

    public function findEmployeeById($employee_id)
    {
      return $this::with('image')->find($employee_id);
    }

    public function add($data)
    {
      return self::create($data);
    }

    public static function updateInfo($data)
    {
      return self::update($data);
    }

    public function del($employee_id)
    {
      return self::destroy($employee_id);
    }

    public function getAll()
    {
      return $this->select();
    }
}
